package com.breeze.components.mybatis.page;

import com.mybatisflex.core.paginate.Page;
import java.util.List;
import lombok.Data;

/**
 * 分页模型类
 *
 * @author breeze
 */
@Data
public class PageDTO<T> {

  /** 总记录数 */
  private Long total;

  /** 列表数据 */
  private List<T> rows;

  public PageDTO(List<T> list) {
    this.rows = list;
    this.total = (long) list.size();
  }

  public PageDTO(Page<T> page) {
    this.rows = page.getRecords();
    this.total = page.getTotalRow();
  }

  public PageDTO(List<T> list, Long count) {
    this.rows = list;
    this.total = count;
  }
}
